//
//  ThreeImageCell.m
//  太平洋电脑网
//
//  Created by dllo on 16/6/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ThreeImageCell.h"
#import "UIImageView+WebCache.h"

@interface ThreeImageCell ()

@property (nonatomic,retain)UILabel *titleLable;
@property (nonatomic,retain)UIImageView *firImageView;
@property (nonatomic,retain)UIImageView *secImageView;
@property (nonatomic,retain)UIImageView *thiImageView;
@property (nonatomic,retain)UIImageView *fouImageView;
@property (nonatomic,retain)UILabel *firLable;
@property (nonatomic,retain)UILabel *secLable;
@property (nonatomic,retain)UILabel *thiLable;

@end

@implementation ThreeImageCell
-(void)dealloc{
    [_model release];
    [_titleLable release];
    [_firImageView release];
    [_secImageView release];
    [_thiImageView release];
    [_fouImageView release];
    [_firLable release];
    [_secLable release];
    [_thiLable release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.titleLable = [[UILabel alloc]init];
        [self.contentView addSubview:self.titleLable];
        [_titleLable release];
        self.firImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.firImageView];
        [_firImageView release];
        self.secImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.secImageView];
        [_secImageView release];
        self.thiImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.thiImageView];
        [_thiImageView release];
        self.fouImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.fouImageView];
        [_fouImageView release];
        self.fouImageView.image = [UIImage imageNamed:@"人.png"];
        self.firLable = [[UILabel alloc]init];
        [self.contentView addSubview:self.firLable];
        [_firLable release];
        self.secLable = [[UILabel alloc]init];
        [self.contentView addSubview:self.secLable];
        [_secLable release];
        self.thiLable = [[UILabel alloc]init];
        [self.contentView addSubview:self.thiLable];
        [_thiLable release];
        UILabel *fouLable = [[UILabel alloc]initWithFrame:CGRectMake(0, 209, 414, 1)];
        fouLable.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:fouLable];
        [fouLable release];
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    self.titleLable.frame = CGRectMake(10, 10, 414 - 20, 50);
    self.titleLable.numberOfLines = 0;
    self.firImageView.frame = CGRectMake(10, 70, 120, 100);
    self.secImageView.frame = CGRectMake(140, 70, 120, 100);
    self.thiImageView.frame = CGRectMake(270, 70, 120, 100);
    
    self.fouImageView.frame = CGRectMake(10, 180, 20, 20);
    self.firLable.frame = CGRectMake(30, 180, 150, 20);
    self.secLable.frame = CGRectMake(180, 180, 100, 20);
    self.thiLable.frame = CGRectMake(280, 180, 404-290, 20);
    
    self.firLable.textColor = [UIColor grayColor];
    self.secLable.textColor = [UIColor grayColor];
    self.thiLable.textColor = [UIColor grayColor];
    self.thiLable.textAlignment = NSTextAlignmentRight;
    
}
- (void)setModel:(Model *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    //根据数组的个数来赋值
    self.titleLable.text = model.title;
    if (model.imgUrls.count ==1 ) {
        [self.firImageView sd_setImageWithURL:[NSURL URLWithString:model.imgUrls[0]]];
    }else if(model.imgUrls.count ==2 ){
        [self.firImageView sd_setImageWithURL:[NSURL URLWithString:model.imgUrls[0]]];
        [self.secImageView sd_setImageWithURL:[NSURL URLWithString:model.imgUrls[1]]];
    }else{
        [self.firImageView sd_setImageWithURL:[NSURL URLWithString:model.imgUrls[0]]];
        [self.secImageView sd_setImageWithURL:[NSURL URLWithString:model.imgUrls[1]]];
        [self.thiImageView sd_setImageWithURL:[NSURL URLWithString:model.imgUrls[2]]];
    }
    self.firLable.text = model.userName;
    NSString *str = [model.lastPostAt substringFromIndex:5];
    NSString *str2 = [str substringToIndex:5];
    self.secLable.text = str2;
    self.thiLable.text = [NSString stringWithFormat:@"%ld阅/%ld回",model.viewCount,model.replyCount];
    
    
    
    
    
    
}


























































@end

























